$( document ).ready(function() {
	loadConceptMaps();
});


function loadConceptMaps() {
	$.getJSON("listconceptmap.json",{ajax : 'true'},
		function(data) { 	 	
		var length = data.length;
		$('#lstConceptMaps').html('');
		for (var i = 0; i < length; i++) {
			$('#lstConceptMaps').append($('<option>', {
			    value: data[i].idConceptMaps,
			    text: data[i].nameConceptMaps,
			}));
		}
	})
}

function createAssignment() {
    var idConceptMaps  = $( "#lstConceptMaps" ).val();
	var name = $('#name').val();
	var startTime = $('#starttime').val();
	var deadline  = $('#deadline').val();
	var idMember  = $('#member').val();
    var json = {"idConceptMaps": idConceptMaps, "name" : name, "startTime": startTime, "deadline": deadline, "idMember": idMember};
    $.ajax({
	    url: "addAssignment.json",
	    type: 'POST',
	    dataType: 'json',
	    data: JSON.stringify(json),
	    contentType: 'application/json',
	    mimeType: 'application/json',
	    success: function(data) {
	    	alert("Created assignment!");
	   	},
	    error: function() {
	    	alert("Error");
	    }
	}); 	
}